package com.example.sxproject.service.impl;

import com.example.sxproject.mapper.FinancialMapper;
import com.example.sxproject.pojo.FPSearch;
import com.example.sxproject.pojo.FinancialProduct;
import com.example.sxproject.pojo.FinancialUser;
import com.example.sxproject.service.FinancialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FinancialServiceImpl implements FinancialService {

    @Autowired
    private FinancialMapper financialMapper;

    //查询select：全部
    @Override
    public List<FinancialProduct> SelectAll() {
        List<FinancialProduct> products =  financialMapper.SelectAll();
        return products;
    }

    //查询select：根据用户id查找
    @Override
    public List<FinancialUser> findByUserId(Integer userId) {
        List<FinancialUser> products =  financialMapper.findByUserId(userId);
        return products;
    }

    //查找：根据id查找
    @Override
    public FinancialProduct findByProductId(Integer productId) {
        FinancialProduct product =  financialMapper.findByProductId(productId);
        return product;
    }

    //查询select：根据用户名查找
    @Override
    public List<FinancialProduct> SelectByUserId(Integer userId) {
        List<FinancialProduct> products = financialMapper.SelectByUserId(userId);
        return products;
    }

    //查询select：根据销售状态查找
    @Override
    public List<FinancialProduct> SelectFPSearch(FPSearch fpSearch) {
        List<FinancialProduct> products = financialMapper.SelectFPSearch(fpSearch);
        return products;
    }

    //添加insert：添加一个产品
    @Override
    public void addFinancialProduct(FinancialProduct financialProduct) {
        financialMapper.addFinancialProduct(financialProduct);
    }

    //添加insert：添加一个用户-产品
    @Override
    public void addUserAndProduct(FinancialUser financialUser) {
        financialMapper.addUserAndProduct(financialUser);
    }

    //更新update：更新记录
    @Override
    public void update(FinancialProduct financialProduct) {
        financialMapper.update(financialProduct);
    }

    //更新update：更新用户-产品记录
    @Override
    public void updateUP(FinancialUser financialUser) {
        financialMapper.updateUP(financialUser);
    }

    //更新update：根据id进行假删除
    @Override
    public void delete(FinancialProduct financialProduct) {
        financialMapper.delete(financialProduct);
    }

    //管理员查询用户所拥有的理财产品
    @Override
    public List<FinancialUser> selectFu(FinancialUser financialUser) {
        List<FinancialUser> financialUsers =  financialMapper.selectFu(financialUser);
        return financialUsers;
    }

}
